<template>
	<view class="shop-home">
		<view class="home-hade" :style="{height:(StateVh + 150) + 'px'}">
		</view>
		<view class="home-card" :style="{paddingTop:response+'px'}">
			<view class="hade-flex">
				<view class="hade-avatar">
					<view class="avatar-box">
						<u-avatar border
							src="https://img.jrtyt.com/uploads/image/20231106/f4955d0b25bcce21e2cedd8a4a80c9b3.jpeg"
							size="50"></u-avatar>
					</view>
					<view class="avatar-name">旅客</view>
				</view>
				<view class="hade-menu">
					<view class="menu-item">
						<view class="menu-icon">
							<u-icon name="share" size="25" color="#333"></u-icon>
						</view>
					</view>
					<view class="menu-item">
						<view class="menu-icon">
							<u-icon name="search" size="25" color="#333"></u-icon>
						</view>
					</view>
				</view>
			</view>
			<scroll-view :scroll-top="scrolltop" :refresher-triggered="refresh" @refresherabort="scrollEnd"
				refresher-enabled @refresherpulling="scrollStart" scroll-y class="hade-scroll"
				:style="{height:screen - (tabbar_h + distance_top) + 'px'}">
				<shop-commodity />
				<button class="increase-product cu-btn">
					<view class="increase-icon">
						<u-icon name="plus-circle" color="#000" size="25"></u-icon>
					</view>
					上架特产
				</button>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "home",
		data() {
			return {
				refresh: false,
				time:null
			};
		},
		computed: {
			distance_top() {
				return (this.response + 50)
			}
		},
		methods: {
			scrollStart(e) {
				const { dy} = e.detail
				if(!this.refresh){
					clearTimeout(this.time)
					this.time = setTimeout(()=>{
						if(dy >=40){
							this.refresh = true
							setTimeout(()=>{
								this.refresh = false
							},2000)
						}
					},500)
				}
			},
			scrollEnd() {
				this.loading = false
			}
		}
	}
</script>

<style lang="scss">
	.increase-product{
		margin-top: 20rpx;
		width: 100%;
		height: 80rpx;
		background-color: #FFF !important;
		border-radius: 3px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		font-weight: bold;
		color: #000;
		.increase-icon{
			margin-right: 8rpx;
		}
	}
	.home-card {
		position: absolute;
		top: 0;
		left: 0;
		padding: 0 30rpx 0 30rpx;
		width: 100%;

		.hade-flex {
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 50px;

			.hade-menu {
				display: flex;
				align-items: center;

				.menu-item {
					width: 75rpx;
					height: 75rpx;
					background: rgba(255, 255, 255, 0.5);
					border-radius: 50%;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-left: 30rpx;
				}
			}

			.hade-avatar {
				display: flex;
				align-items: center;

				.avatar-name {
					font-size: 35rpx;
					color: #000;
					font-weight: bold;
					margin-left: 20rpx;
				}
			}
		}
	}

	.home-hade {
		width: 100%;
		position: relative;
		background: #FFCF4F;
	}
</style>
